package com.potenza.test.service;

import com.potenza.test.annotation.Master;
import com.potenza.test.mapper.MemberMapper;
import com.potenza.test.model.Member;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserServiceImpl {

  private MemberMapper memberMapper;

  @Transactional
  public int insert(Member member) {
    return memberMapper.insert(member);
  }

  @Master
  public int save(Member member) {
    return memberMapper.insert(member);
  }

  public List<Member> selectAll() {
    return memberMapper.selectAll();
  }

  @Master
  public String getToken(String appId) {
    //  有些读操作必须读主数据库
    //  比如，获取微信access_token，因为高峰时期主从同步可能延迟
    //  这种情况下就必须强制从主数据读
    return null;
  }
}